from datetime import datetime
from typing import Optional
from sqlmodel import Field, SQLModel
from .base import Base


class TagGroupInfo(Base, table=True):
    """标签分组表"""
    id: int = Field(default=None, primary_key=True)
    title: str = Field(default=None, description='标签名称')
    parent_id: int = Field(default=None, description='标签名称')
    status: bool = Field(default=0, description='标签名称')
    desc: str = Field(default=None, description='标签名称')
    __tablename__ = "tag_group_info"


class TagInfo(Base, table=True):
    id: int = Field(default=None, primary_key=True, description='自增ID')
    title: str = Field(default=None, description='标签名称')
    group_id: int = Field(default=None, description='标签名称')
    status: bool = Field(default=0, description='标签名称')
    code: str = Field(default=None, description='标签名称')
    desc: str = Field(default=None, description='标签名称')
    __tablename__ = "tag_info"


class TagDataLink(SQLModel, table=True):
    id: int = Field(primary_key=True)
    tag_id: int = Field(index=True)
    tag_value: str = Field(default=None)
    link_id: int = Field(index=True)
    deleted: Optional[int] = Field(default=0)
    create_time: datetime = Field(default=datetime.now(), index=True, description='创建时间')
    update_time: datetime = Field(default=datetime.now(), index=True, description='更新时间')
    __tablename__ = "tag_data_link"
